$(document).ready(function(){

show_text_area_status=function(ops)
{
var idn=$('#'+ops.idn);
var classShow=$('.'+ops.classShow);
var textarea_auto=document.getElementById(ops.idn);
textarea_auto.style.backgroundColor='#ffffff';textarea_auto.style.color='#000';textarea_auto.style.height='auto';
if(idn.attr('rows')<3){
idn.attr('rows',3);}
classShow.show();
}

add_comment_text=function(option)
{
	var id=$('#'+option.id);
	var newid=$('#new'+option.id);
	id.focusout(function(){
	id.unbind('keypress');
	return false;
	});
		
	id.keypress(function(event){
	if(event.which==13)
	{	
		$.ajax({
		url:"http://localhost/hoidap/Source/comments/index/add",
		data:{content: $(id).val(), author: option.author, parent: option.id },
		type:'post',
		dataType:'html',
		success:function(html)
		{	
			$(newid).append(html);
			id.val('');
			return false;			 
		}
		});
	
	}	
	});
	return false;	
}

catelogy_select_text=function(option)
{
	var id=$('#'+option.id);

	if(option.parent == 0)
	{	
		$(id).html("<select  name='categories_con'><option value='0'>Chọn Danh mục câu hỏi</option></select>");
		return false;
	}
	else if(option.parent == -1)
	{	
	//	$(id).html("<select  name='categories_con'><option value='0'>Chọn Danh mục câu hỏi</option></select>");
		catelogy_select_listall();
		return false;
	}		
	else
	{	
			$.ajax({
			url:"http://localhost/hoidap/Source/categories",
			data:{name:'con', parent: option.parent, limit: 0},
			type:'post',
			dataType:'html',
			success:function(html)
			{
				$(id).html(html);
				return false;			 
			}
			});
		return false;	
	}
}


catelogy_select_listall=function()
{		
		var id=$('#select_cat');
		$.ajax({
		url:"http://localhost/hoidap/Source/categories",
		data:{name:'cha', parent: 0, limit: 0},
		type:'post',
		dataType:'html',
		success:function(html)
		{	
			$(id).html(html);
			return false;			 
		}
		});
		return false;	
}






});